package com.intermancer.predictor.store;

import java.util.List;

/**
 * Implementations of StoreEntryDAO are inherently sorted by StoreEntry.score.
 * 
 * @author johnfryar
 * 
 */
public interface StoreEntryDAO {

	int NO_MAXIMUM_SIZE = -1;

	/**
	 * Retrieve a StoreEntry based on identity.
	 * 
	 * @param identity
	 * @return
	 */
	StoreEntry get(Long identity);

	/**
	 * This method is not expected to retain the identity of the given
	 * StoreEntry. Refer to the identity of the returned StoreEntry for the
	 * value that was used.
	 * 
	 * @param storeEntry
	 * @return A StoreEntry with the correct identity. May or may not be the
	 *         actual instance that was passed to the method.
	 */
	StoreEntry put(StoreEntry storeEntry);

	/**
	 * Delete a StoreEntry based on identity;
	 * 
	 * @param identity
	 */
	void delete(Long identity);

	/**
	 * @return The identities of all managed StoreEntries.
	 */
	List<Long> getIdentities();

	/**
	 * Get a List of StoreEntries based on a List of identities.
	 * 
	 * @param identities
	 * @return A List that is not guaranteed to be the same size as the
	 *         identities which were passed to it.
	 */
	List<StoreEntry> get(List<Long> identities);

	/**
	 * @return The current number of StoreEntries.
	 */
	int getSize();

	/**
	 * @return The maximum size for the Store. If the returned value is
	 *         NO_MAXIMUM_SIZE then there is no explicit maximum size, though
	 *         the maximum value of int is still an implied upper bound.
	 */
	int getMaxSize();

	/**
	 * @param index
	 * @return Viewing a Store as a set of StoreEntries sorted by score,
	 *         implementations of this method return the StoreEntry with the
	 *         given index.
	 */
	StoreEntry getByScoreIndex(int index);

	/**
	 * @param score
	 * @return The index that a StoreEntry record with the given score would
	 *         have if added to the StoreEntryDAO
	 */
	int getScoreIndex(double score);

}
